/* Copyright (c) 1997-2010
   Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Darmstadt, Germany)
   http://www.polymake.de

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version: http://www.gnu.org/licenses/gpl.txt.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
--------------------------------------------------------------------------------
   $Project: polymake $$Id: fstream 9432 2010-02-01 23:30:24Z gawrilow $
*/

#ifndef _POLYMAKE_FSTREAM_H
#define _POLYMAKE_FSTREAM_H

#include_next <fstream>

namespace pm {

class FileBuffer : public std::filebuf {
private:
   // never create
   FileBuffer();
   ~FileBuffer();
public:
   static int get_fd(std::filebuf *_buf)
   {
      FileBuffer *buf=static_cast<FileBuffer*>(_buf);
#if defined(__GNUC__)
      return buf->_M_file.fd();
#elif defined(__INTEL_COMPILER)
      return buf->fd();
#else
# error "don't know how to query the file descriptor"
#endif
   }
};

} // end namespace pm

#endif // _POLYMAKE_FSTREAM_H

// Local Variables:
// mode:C++
// End:
